import axios from 'axios'

const service = axios.create({
  baseURL: 'http://localhost:8000',
  timeout: 5000
})

service.interceptors.request.use(
  config => {
    const role = localStorage.getItem('role') || '';
    config.headers['Authorization'] = localStorage.getItem('token') || '';
    config.headers['X-User-Role'] = role;
    return config
  },
  error => Promise.reject(error)
)

export default service